package com.lh.tams.controller.system;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lh.tams.domain.TamsTime;
import com.lh.tams.service.system.TimeService;
import com.lh.tams.util.DataGridModel;
import com.lh.tams.util.ID;
import com.lh.tams.util.Page;
import com.lh.tams.util.diy.Json;

/**
 * 时限管理controller
 * @author liulin
 * @version 2012-11-20
 */
@RequestMapping("/time")
@Controller
public class TimeController {
	private TimeService timeService;

	public TimeService getTimeService() {
		return timeService;
	}

	public void setTimeService(TimeService timeService) {
		this.timeService = timeService;
	}

	@RequestMapping("/query.adm")
	@ResponseBody
	public Page query(DataGridModel dgm,TamsTime tamsTime){
		return timeService.query(dgm, tamsTime);
	}
	
	@RequestMapping("/add.adm")
	@ResponseBody
	public Json add(TamsTime tamsTime){
		
		tamsTime.setIdBgt(ID.next());
		tamsTime.setRemark(tamsTime.getRemark().trim());
		timeService.add(tamsTime);
		Json json = new Json();
		return json;
	}
	
	@RequestMapping("/update.adm")
	@ResponseBody
	public Json update(TamsTime tamsTime){
		tamsTime.setRemark(tamsTime.getRemark().trim());
		timeService.update(tamsTime);
		Json json = new Json();
		return json;
	}
	
	@RequestMapping("/del.adm")
	@ResponseBody
	public Json delete(long[] id){
		timeService.delete(id);
		return new Json();
	}
	
	@RequestMapping("/flash.adm")
	@ResponseBody
	public Json flash(){
		timeService.flash();
		Json json = new Json();
		return json;
	}
}
